<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />
<div class="t_bar">
	投入经费情况（单位：万元）
</div>
<table class="t_css" width="100%" border="0" cellpadding="0"
	cellspacing="1"  id="budgetsMsg">
	<tr>
		<td  nowrap align="right"><span class="color_red">*</span>实际投入资金总额：</td>
		<td ><input type="text" style="text-align: right;width: 100px"
			name="budgets/input_total" id="source_total"
			class="required" 
			label="投入经费情况-->实际投入资金总额" 
			value="<x:out select="$xmlData/data/budgets/input_total" />"
			onchange="synchro();"
			onfocus="InitInput.setNumber(this,9,4,2)" />
			<input type="hidden" style="text-align: right;width: 100px"
			name="budgets/already_input_total" id="source_already"
			class="required gray valueEqual:source_already:total_total_0" label="实际投入资金来源合计" disabled
			value="<x:out select="$xmlData/data/budgets/already_input_total" />"
			onfocus="InitInput.setNumber(this,9,4,2)" />
			</td>
		<td align="right"><span class="color_red">*</span>申请金额：</td>
		<td ><input type="text"
			style="text-align: right;width: 100px" name="budgets/apply_money"
			id="source_apply"
			class="required " label="投入经费情况-->申请金额"
			onchange="synchro();"
			value="<x:out select="$xmlData/data/budgets/apply_money" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>



	</tr>
</table>
<br/>
<div class="t_bar">
	<span class="color_red">*</span>实际投入资金来源（单位：万元）
</div>
<table class="t_css" width="100%" border="0" cellpadding="0"
	cellspacing="1"  id="budgetsMsg1">
	<tr align="center" class="li_2">
		<td rowspan="2">自有资金</td>
		<td rowspan="2">银行贷款</td>
		<td colspan="4">获得资助</td>
		<td rowspan="2" >其他资金</td>
	</tr>
	<tr align="center" class="li_2">
		<td>国家</td>
		<td>省级</td>
		<td>市级</td>
		<td>区级</td>
	</tr>
	<tr class="li_1">
		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/own_fund_over" id="source_own_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');synchro();"
			class="required" label="实际投入资金来源-->自有资金"
			value="<x:out select="$xmlData/data/budgets/own_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/bank_fund_over" id="source_bank_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');synchro();"
			class="required" label="实际投入资金来源-->银行贷款"
			value="<x:out select="$xmlData/data/budgets/bank_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

	

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/country_fund_over" id="source_country_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');synchro();"
			class="required" label="实际投入资金来源-->获得资助（国家）"
			value="<x:out select="$xmlData/data/budgets/country_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/provincial_fund_over" id="source_provincial_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');synchro();"
			class="required" label="实际投入资金来源-->获得资助（省级）"
			value="<x:out select="$xmlData/data/budgets/provincial_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>

		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/city_fund_over" id="source_city_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');synchro();"
			class="required " label="实际投入资金来源-->获得资助（市级）"
			value="<x:out select="$xmlData/data/budgets/city_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/area_fund_over" id="source_area_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');synchro();"
			class="required" label="实际投入资金来源-->获得资助（区级）"
			value="<x:out select="$xmlData/data/budgets/area_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		
	<td><input type="text" style="text-align: right; width: 100px"
			name="budgets/other_fund_over" id="source_other_over"
			onchange="countFundAuto('source_','own_over,bank_over,other_over,country_over,provincial_over,city_over,area_over','already');synchro();"
			class="required " label="实际投入资金来源-->其他资金"
			value="<x:out select="$xmlData/data/budgets/other_fund_over" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>	
			
	</tr>

</table>

<br/>
<div class="t_bar">
	<span class="color_red">*</span>实际投入资金支出（单位：万元）
</div>
<table class="t_css" width="100%" border="0" cellpadding="0"
	cellspacing="1" id="fundAdds">

	<tr >
		<td class="TblHead" align="center"  width="20%">支出科目</td>
		<td class="TblHead" align="center" width="20%">金额</td>
		<td class="TblHead" align="center" width="60%" >备注</td>
	</tr>
	
	<tr>
		<td align="align" >合计</td>
		<td><input type="hidden"
			name="budget/invest_detail/invest[00]@invest_code" value="00" /> <input
			type="hidden" name="budget/invest_detail/invest[00]/name" value="合计" />
			<input type="text" name="budget/invest_detail/invest[00]/total_total"
			id="total_total_0" class="gray valueEqual:source_total:total_total_0" disabled
			style="text-align: right; width: 100px;" label="实际投入资金支出-->合计"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='00']/total_total" />" />
		</td>
		<td><input type="text" style="width: 90%" class="required" label="实际投入资金支出合计-->备注" name="budget/invest_detail/invest[00]/user_desc"  maxlength="200"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='00']/user_desc" />"/></td>
	</tr>

	<tr>
		<td align="left" >1、并购款</td>
		<td><input type="hidden"
			name="budget/invest_detail/invest[01]@invest_code" value="01" /> <input
			type="hidden" name="budget/invest_detail/invest[01]/name"
			value="1、并购款" /> <input type="text"
			style="text-align: right; width: 100px" class="required "  label="实际投入资金支出-->并购款"
			name="budget/invest_detail/invest[01]/total_total" id="total_total_1"
			onchange="countFundAuto('total_','total_1,total_2,total_3,total_4,total_5','total_0');"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='01']/total_total" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td><input type="text" style="width: 90%" class="required" label="并购款-->备注" name="budget/invest_detail/invest[01]/user_desc"  maxlength="200"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='01']/user_desc" />"/></td>
	</tr>
	<tr>
		<td align="left" >2、评估费</td>
		<td><input type="hidden"
			name="budget/invest_detail/invest[02]@invest_code" value="02" /> <input
			type="hidden" name="budget/invest_detail/invest[02]/name"
			value="2、评估费" /> <input type="text" label="实际投入资金支出-->评估费" 
			style="text-align: right; width: 100px" class="required " 
			name="budget/invest_detail/invest[02]/total_total" id="total_total_2"
			onchange="countFundAuto('total_','total_1,total_2,total_3,total_4,total_5','total_0');"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='02']/total_total" />"
			onfocus="InitInput.setNumber(this,9,4,2)" /></td>
		<td><input type="text" style="width: 90%" class="required" label="评估费-->备注" name="budget/invest_detail/invest[02]/user_desc"  maxlength="200"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='02']/user_desc" />"/></td>
		
	</tr>
	<tr>
		<td align="left" >3、律师费</td>
		<td><input type="hidden"
			name="budget/invest_detail/invest[03]@invest_code" value="03">
			<input type="hidden" name="budget/invest_detail/invest[03]/name"
			value="3、律师费"> <input type="text" label="实际投入资金支出-->律师费"
			name="budget/invest_detail/invest[03]/total_total" 
			style="text-align: right; width: 100px;" id="total_total_3" class="required " 
			onfocus="InitInput.setNumber(this,9,4,2)"
			onchange="countFundAuto('total_','total_1,total_2,total_3,total_4,total_5','total_0');"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='03']/total_total" />" />
		</td>
		
		<td><input type="text" style="width: 90%" class="required" label="律师费-->备注" name="budget/invest_detail/invest[03]/user_desc"  maxlength="200"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='03']/user_desc" />"/></td>
	</tr>
	<tr>
		<td align="left" >4、中介费</td>
		<td><input type="hidden"
			name="budget/invest_detail/invest[04]@invest_code" value="04">
			<input type="hidden" name="budget/invest_detail/invest[04]/name"
			value="4、中介费"> <input type="text" label="实际投入资金支出-->中介费"
			name="budget/invest_detail/invest[04]/total_total"  class="required " 
			style="text-align: right; width: 100px;" id="total_total_4"
			onfocus="InitInput.setNumber(this,9,4,2)"
			onchange="countFundAuto('total_','total_1,total_2,total_3,total_4,total_5','total_0');"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='04']/total_total" />" />
		</td>
		
		<td><input type="text" style="width: 90%" class="required" label="中介费-->备注" name="budget/invest_detail/invest[04]/user_desc"  maxlength="200"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='04']/user_desc" />"/></td>
	</tr>
	<tr>
		<td align="left" >5、其他费用</td>
		<td><input type="hidden"
			name="budget/invest_detail/invest[05]@invest_code" value="05">
			<input type="hidden" name="budget/invest_detail/invest[05]/name"
			value="5、其他费用"> <input type="text" label="实际投入资金支出-->其他费用"
			name="budget/invest_detail/invest[05]/total_total"  class="required " 
			style="text-align: right; width: 100px;" id="total_total_5"
			onfocus="InitInput.setNumber(this,9,4,2)"
			onchange="countFundAuto('total_','total_1,total_2,total_3,total_4,total_5','total_0');"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='05']/total_total" />" />
		</td>
		
		<td><input type="text" style="width: 90%" class="required" label="其他费用-->备注" name="budget/invest_detail/invest[05]/user_desc"  maxlength="200"
			value="<x:out select="$xmlData/data/budget/invest_detail/invest[@invest_code='05']/user_desc" />"/></td>
	</tr>
</table>
<br/>

<script type="text/javascript">
$(document).ready(function() {
var prp_version=$("#prp_version").text();

if(prp_version==""||prp_version==null){
	$("#budgetsMsg").find(":input").each(function(){
	$(this).val("0.00");	
	});
	
	$("#budgetsMsg1").find(":input").each(function(){
		$(this).val("0.00");	
		});
	
	 $("#fundAdds").find(":input[type!=hidden][id^=total_total]").each(function(){
		$(this).val("0.00");	
		});
}


	//$("#source_city").attr("disabled",true);
	//$("#source_area").attr("disabled",true);
	//$("#source_city").addClass("gray");
	//$("#source_area").addClass("gray");

	
});

function synchro(){
	var source_apply = $("#source_apply").val();
	var source_total = $("#source_total").val();
	var source_already = $("#source_already").val();
	$("#sqje").val(formatVal2(source_apply));
	$("#investment_budget").val(formatVal2(source_total));
	$("#finsh_budget").val(formatVal2(source_already));
	  
	
}

function countjsTotal(obj) {
	
	var price = $(obj).parent().parent().find("[name$='price']").val();
	var amount = $(obj).parent().parent().find("[name$='amount']").val();
	
	if (!$.isNumeric(price) || !$.isNumeric(amount) ) {
		$(obj).parent().parent().find("[name$='money']").val("");
	} else {
		var count = Math.round(parseFloat(price)*10000 * parseInt(amount,10))/10000;
		count = formatNumberAuto(count.toString(), 9, 4, 2);// 格式化金额
		$(obj).parent().parent().find("[name$='money']").val(count);
	}
	
}

function countjsTable2(tblId){
	
    
	  
   var count2=0;
   var count3=0;
   var count4=0;
   var count5=0;
   
   var countEx2=0;
   var countEx3=0;
   var countEx4=0;
   var countEx5=0;
   
   var count = 0;
   var countFund = 0;
   
   $("#"+tblId+" tr:gt(1)").each(function() {
	   var fund = $(this).children().eq("4").children().val();
	   var fund2 = $(this).children().eq("5").children().val();
	   var fund3 = $(this).children().eq("6").children().val();
	   
	   var device_way_value = $(this).children().eq("3").children().val();
	   
	   if (!$.isNumeric(fund))  fund = "0";
	   if (!$.isNumeric(fund2)) fund2 = "0";
	   if (!$.isNumeric(fund3)) fund3 = "0";
	   
	   count=parseInt(fund2)+parseInt(count);
	   countFund = ((parseFloat(countFund)*10000 + parseFloat(fund3)*10000)/10000).toFixed(4);
	  
	   if(parseFloat(fund)>parseFloat(5)){
		   if(device_way_value=='01') {
			   count2=parseInt(fund2)+parseInt(count2);
			   count4 = ((parseFloat(count4)*10000 + parseFloat(fund3)*10000)/10000).toFixed(4);
		   } else if(device_way_value=='02') {
			   countEx2=parseInt(fund2)+parseInt(countEx2);
			   countEx4 = ((parseFloat(countEx4)*10000 + parseFloat(fund3)*10000)/10000).toFixed(4);
		   }
	   }else{
		   if(device_way_value=='01') {
			   count3=parseInt(fund2)+parseInt(count3);
			   count5=((parseFloat(count5)*10000 + parseFloat(fund3)*10000)/10000).toFixed(4);
		   } else if(device_way_value=='02') {
			   countEx3=parseInt(fund2)+parseInt(countEx3);
			   countEx5=((parseFloat(countEx5)*10000 + parseFloat(fund3)*10000)/10000).toFixed(4);
		   }
	   }
   });
	
   count = formatNumberAuto(count.toString(), 9, 0, 0);
   
	   count2 = formatNumberAuto(count2.toString(), 9, 0, 0);// 格式化金额
	   count3 = formatNumberAuto(count3.toString(), 9, 0, 0);// 格式化金额
	   count4 = formatNumberAuto(count4.toString(), 9, 4, 2);// 格式化金额
	   count5 = formatNumberAuto(count5.toString(), 9, 4, 2);// 格式化金额
	   
	   countEx2 = formatNumberAuto(countEx2.toString(), 9, 0, 0);// 格式化金额
	   countEx3 = formatNumberAuto(countEx3.toString(), 9, 0, 0);// 格式化金额
	   countEx4 = formatNumberAuto(countEx4.toString(), 9, 4, 2);// 格式化金额
	   countEx5 = formatNumberAuto(countEx5.toString(), 9, 4, 2);// 格式化金额
	  
	   countFund = formatNumberAuto(countFund.toString(), 9, 4, 2);// 格式化金额
	   
   	  $("#list_amount_1").val(count2); 
	  $("#list_money_1").val(count4); 
	  $("#list_amount_2").val(countEx2);
	  $("#list_money_2").val(countEx4);
	  
	  $("#list_amount_3").val(count3); 
	  $("#list_money_3").val(count5); 
	  
	  $("#list_amount_4").val(countEx3);
	  $("#list_money_4").val(countEx5);
	  
	  $("#list_amount_5").val(count); 
	  $("#list_money_5").val(countFund); 
	}
</script>
